﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "GmInplaceEdit.h"
#include "NdbObjectSchematic.h"
#include "IDbObject.h"
#include "DbDataSchema.h"

namespace gcmp
{
    // 跨进程调用传输的数据对象基类
    class GM_INPLACE_EDIT_EXPORT RpcSharedObject : public NdbObjectSchematic, public IDbObject
    {
        DBOBJECT_DATA_BEGIN_AND_QUICK_CAST_FROM(gcmp, RpcSharedObject, gcmp::NdbObjectSchematic, 4A4CB856 - 226C - 4765 - B858 - 8BFA12CF0C0B, gminplaceedit, gcmp::IDbObject)
        DBOBJECT_DATA_END

    public: //实现NdbObject接口
        virtual NdbObject* GetTopOwnerObject() const override
        {
            return nullptr;
        }
    };

    // 进程基本信息
    class GM_INPLACE_EDIT_EXPORT RpcServerInfo : public RpcSharedObject
    {
        DBOBJECT_DATA_BEGIN(gcmp, RpcServerInfo, gcmp::RpcSharedObject, 5178971A - E613 - 4D2F - A3BA - 0787BB8230C7, gminplaceedit)
            DATA(Guid, ServerGuid)
            DATA(UInt16, Port)
            DATA(std::wstring, AppName)
        DBOBJECT_DATA_END

    public:
        RpcServerInfo(const GUID& serverGuid, uint16_t port, const std::wstring& appName);

    public:
        Guid GetServerGuid() const { return this->GetServerGuid__(); }
        uint16_t GetPort() const { return this->GetPort__(); }
        std::wstring GetAppName() const { return this->GetAppName__(); }
    };

}// namespace gcmp
